; Include Modern UI stylings
!include "MUI.nsh"

Name "VRML Toolbox"
OutFile "VRML Toolbox.exe"
InstallDir $PROGRAMFILES\VRMLToolbox
SetCompressor lzma

; Version information
VIProductVersion 1.0.0.0
VIAddVersionKey ProductName "VRML Toolbox"
VIAddVersionKey ProductVersion "1.0"
VIAddVersionKey FileVersion "1.0"
VIAddVersionKey FileDescription "VRML Toolbox Installer"
VIAddVersionKey LegalCopyright ""

;--------------------------------
; Pages
  
; Installer pages
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

; Uninstall pages
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------

; The stuff to install
Section "" ;Can't be disabled

  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
  ; Write uninstaller
  WriteUninstaller Uninstall.exe
  
  ; Menu shortcuts
  SetShellVarContext all
  CreateDirectory "$SMPROGRAMS\VRML Toolbox"
  CreateShortCut "$SMPROGRAMS\VRML Toolbox\Uninstall.lnk" "$INSTDIR\Uninstall.exe"

  ; Add uninstall info to add/remove programs list
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRMLToolbox" "DisplayName" "VRML Toolbox"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRMLToolbox" "UninstallString" "$INSTDIR\Uninstall.exe"
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRMLToolbox" "NoRepair" "1"
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRMLToolbox" "NoModify" "1"

SectionEnd

Section "Dizzy" Dizzy

  SetOutPath $INSTDIR\Dizzy

  ; Files
  File Dizzy\Release\Dizzy.exe
  File Dizzy\Release\Dizzy.hlp
  File Dizzy\Release\Dizzy.cnt
  File Dizzy\readme.txt

  ; Create shortcuts
  SetShellVarContext all
  CreateShortCut "$SMPROGRAMS\VRML Toolbox\Dizzy.lnk" "$INSTDIR\Dizzy\Dizzy.exe"

SectionEnd

Section "Peek" Peek

  SetOutPath $INSTDIR\Peek

  ; Files
  File Peek\Release\Peek.exe
  File Peek\readme.txt

  ; Create shortcuts
  SetShellVarContext all
  CreateShortCut "$SMPROGRAMS\VRML Toolbox\Peek.lnk" "$INSTDIR\Peek\Peek.exe"

SectionEnd

Section "Twister" Twister

  SetOutPath $INSTDIR\Twister

  ; Files
  File Twister\Release\Twister.exe
  File Twister\readme.txt

  ; Create shortcuts
  SetShellVarContext all
  CreateShortCut "$SMPROGRAMS\VRML Toolbox\Twister.lnk" "$INSTDIR\Twister\Twister.exe"

SectionEnd

Section "SpinDoctor" SpinDoctor

  SetOutPath $INSTDIR\SpinDoctor

  ; Files
  File SpinDoctor\Release\SpinDoctor.exe
  File SpinDoctor\Release\SpinDoctor.hlp
  File SpinDoctor\Release\SpinDoctor.cnt
  File SpinDoctor\readme.txt

  ; Create shortcuts
  SetShellVarContext all
  CreateShortCut "$SMPROGRAMS\VRML Toolbox\SpinDoctor.lnk" "$INSTDIR\SpinDoctor\SpinDoctor.exe"

SectionEnd

Section "Uninstall"

  ; Remove files
  Delete $INSTDIR\Uninstall.exe
  ; Dizzy
  Delete $INSTDIR\Dizzy\Dizzy.exe
  Delete $INSTDIR\Dizzy\Dizzy.hlp
  Delete $INSTDIR\Dizzy\Dizzy.cnt
  Delete $INSTDIR\Dizzy\Dizzy.gid
  Delete $INSTDIR\Dizzy\readme.txt
  ; Peek
  Delete $INSTDIR\Peek\Peek.exe
  Delete $INSTDIR\Peek\readme.txt
  ; Twister
  Delete $INSTDIR\Twister\Twister.exe
  Delete $INSTDIR\Twister\readme.txt
  ; SpinDoctor
  Delete $INSTDIR\SpinDoctor\SpinDoctor.exe
  Delete $INSTDIR\SpinDoctor\SpinDoctor.hlp
  Delete $INSTDIR\SpinDoctor\SpinDoctor.cnt
  Delete $INSTDIR\SpinDoctor\SpinDoctor.gid
  Delete $INSTDIR\SpinDoctor\readme.txt

  ; Remove directories
  RMDir $INSTDIR\Dizzy
  RMDir $INSTDIR\Peek
  RMDir $INSTDIR\Twister
  RMDir $INSTDIR\SpinDoctor
  RMDir $INSTDIR

  ; Remove shortcuts
  SetShellVarContext all
  Delete "$SMPROGRAMS\VRML Toolbox\Dizzy.lnk"
  Delete "$SMPROGRAMS\VRML Toolbox\Peek.lnk"
  Delete "$SMPROGRAMS\VRML Toolbox\Twister.lnk"
  Delete "$SMPROGRAMS\VRML Toolbox\SpinDoctor.lnk"
  Delete "$SMPROGRAMS\VRML Toolbox\Uninstall.lnk"
  ; Remove empty shortcut directories 
  RMDir  "$SMPROGRAMS\VRML Toolbox"

  ; Remove uninstall info from add/remove programs
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRMLToolbox"

SectionEnd

;--------------------------------
; Message String Definitions for Modern UI

!insertmacro MUI_LANGUAGE "English"

LangString DESC_Dizzy ${LANG_ENGLISH} "Dizzy is a 3D axis-angle rotation calculator."
LangString DESC_Peek ${LANG_ENGLISH} "Peek calculates VRML97 Viewpoint nodes."
LangString DESC_Twister ${LANG_ENGLISH} "Twister converts euler angles to axis-angle and vice versa."
LangString DESC_SpinDoctor ${LANG_ENGLISH} "SpinDoctor is a general 3D vector calculator."

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${Dizzy} $(DESC_Dizzy)
  !insertmacro MUI_DESCRIPTION_TEXT ${Peek} $(DESC_Peek)
  !insertmacro MUI_DESCRIPTION_TEXT ${Twister} $(DESC_Twister)
  !insertmacro MUI_DESCRIPTION_TEXT ${SpinDoctor} $(DESC_SpinDoctor)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
